﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.StorageClient;

namespace Thor.Repository.Azure.Table
{
    /// <summary>
    /// Represents a row in the Settings table.
    /// </summary>
    internal class SettingsRow : TableServiceEntity
    {
        #region Constructors

        public SettingsRow() : base() { }

        public SettingsRow(string applicationName, string calendarProviderUri)
            : base(applicationName, calendarProviderUri)
        {
            ApplicationName = applicationName;
            CalendarProviderUri = calendarProviderUri;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Name of the application accessing the table.
        /// </summary>
        public string ApplicationName { get; set; }

        /// <summary>
        /// Whether or not a booking agent is to be used
        /// to book appointments on a calendar.
        /// </summary>
        public bool UseBookingAgent { get; set; }

        /// <summary>
        /// The email address of the booking agent to sent
        /// appointment requests to in the case where
        /// UseBookingAgent == true.
        /// </summary>
        public string BookingAgentEmail { get; set; }

        /// <summary>
        /// The uri of the calendar provider.
        /// </summary>
        public string CalendarProviderUri { get; set; }

        /// <summary>
        /// User name to use when connecting to the CalendarProvider.
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// Password to use when connecting to the CalendarProvider.
        /// </summary>
        public string Password { get; set; }

        /// <summary>
        /// The number of times a user can pass bad credentials into the
        /// application before being locked out.
        /// </summary>
        /// <remarks>
        /// This works in tandem with RetryDuration and LockoutDuration
        /// (i.e. a user can pass
        /// bad credentials into the application five times within an hour
        /// before being locked out.)
        /// </remarks>
        public int RetryCount { get; set; }

        /// <summary>
        /// The duration (in minutes) a user can pass in bad
        /// credentials before being locked out.
        /// </summary>
        /// <remarks>
        /// This works in tandem with RetryDuration and LockoutDuration
        /// (i.e. a user can pass
        /// bad credentials into the application five times within an hour
        /// before being locked out.)
        /// </remarks>
        public int RetryInterval { get; set; }

        /// <summary>
        /// The duration (in minutes) a user is locked out.
        /// </summary>
        /// <remarks>
        /// This works in conjunctions with the RetryCount and RetryInterval
        /// properties (i.e. if a user passes in bad credential five times
        /// within an hour, then the user is locked out for an hour.)
        /// </remarks>
        public int LockoutDuration { get; set; }

        /// <summary>
        /// The name of the assembly that contains the calendar provider.
        /// </summary>
        public string AssemblyName { get; set; }

        /// <summary>
        /// The type within the assembly that contains the calendar provider.
        /// </summary>
        public string AssemblyType { get; set; }

        /// <summary>
        /// The timezone of the server.
        /// </summary>
        public string ServerTimeZone { get; set; }

        /// <summary>
        /// Whether or not the settings are encrypted.
        /// </summary>
        public bool IsEncrypted { get; set; }

        #endregion
    }
}
